import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    visitedRoutes: [{
      name:'首页',
      path:'/admin/'
    }],
    activeIndex: '/admin'
  },
  getters: {
    visitedRoutes: state => {
      return state.visitedRoutes
    }
  },
  mutations: {
    addTagRoutes: (state, route) => {
      if (state.visitedRoutes.find(t => t.path == route.path))
        return
      state.visitedRoutes.push(route)
    },
    removeTagRoutes: (state, route) => {
      state.visitedRoutes.splice(state.visitedRoutes.findIndex(item => item.path === route.path), 1)
    }
  },
  actions: {},
  modules: {}
})